package cn.com.anysdk.oss.factory;

import cn.com.anysdk.oss.api.IOssService;
import cn.com.anysdk.oss.api.IOssConfig;
import cn.com.anysdk.oss.exception.OssException;
import cn.com.anysdk.oss.impl.AliyunOssService;
import cn.com.anysdk.oss.impl.LocalFileSystemService;
import lombok.extern.slf4j.Slf4j;

/**
 * OSS服务工厂
 * 用于创建不同类型的OSS服务实例
 */
@Slf4j
public class OssServiceFactory {
    /**
     * 创建OSS服务实例
     * @param config OSS配置
     * @return OSS服务实例
     */
    public static IOssService createService(IOssConfig config) {
        if (config == null) {
            throw new OssException("OSS config cannot be null");
        }

        String provider = config.getProvider();
        switch (provider.toLowerCase()) {
            case "aliyun":
                return new AliyunOssService(config);
            case "local":
                return new LocalFileSystemService(config);
            default:
                throw new OssException("Unsupported OSS provider: " + provider);
        }
    }
}